package com.yunji.order.service;

import com.yunji.base.dto.PayoutFieldDTO;
import com.yunji.common.base.IModifyStatusBaseBO;
import com.yunji.order.bo.GetAuditApplyBO;
import com.yunji.order.dao.IPayoutDao;
import com.yunji.order.domain.PayoutDO;
import com.yunji.order.dto.PayoutPageDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * @Package com.yunji.order.service.impl
 * FileName:	PayoutServiceImpl.java
 * Copyright:	Copyright © 2024 云集互联 All Rights Reserved
 * Company:		云集互联
 * @version: 1.0
 * @since: JDK 1.8.0_202
 * Create at:   2024-04-21 21:25:29
 * Description:
 * 用户提现接口实现
 * Modification History:
 * Author					Date					Version         Description
 * -------------------------------------------------------------------------------------
 * HuaAo0803@163.com	2024-04-21 21:25:29     1.0             1.0 Version
 */
@Service
public class PayoutService {
    @Autowired
    private IPayoutDao payoutDao;

    public boolean createPayout(PayoutDO payout) {
        return payoutDao.save(payout);
    }

    public boolean updatePayout(PayoutDO payout) {
        return payoutDao.updateById(payout);
    }

    public boolean updatePayout(Long payoutId, Integer newStatus, Integer... oldStatus) {
        return payoutDao.updatePayoutStatus(new IModifyStatusBaseBO<Long>() {
            @Override
            public Long getId() {
                return payoutId;
            }
            @Override
            public Integer getNewStatus() {
                return newStatus;
            }
            @Override
            public List<Integer> getOldStatus() {
                return Arrays.asList(oldStatus);
            }
        });
    }

    public boolean deletePayout(Long... ids) {
        return payoutDao.removeByIds(Arrays.asList(ids));
    }

    public PayoutDO selectPayout(Long payoutId) {
        return payoutDao.getById(payoutId);
    }

    public List<PayoutDO> searchAuditPayout(GetAuditApplyBO bo) {
        return payoutDao.listAuditPayout(bo);
    }

    public PayoutDO selectPayout(String payoutCode) {
        return payoutDao.getByCode(payoutCode);
    }

    public List<String> searchTableField(PayoutFieldDTO param) {
        return payoutDao.searchTableField(param);
    }

    public List<PayoutDO> searchPayout(PayoutPageDTO payout) {
        return payoutDao.payoutPage(payout);
    }
}